package com.remac.framework.mybatisplus.extensions.typehandler.json;

import com.remac.framework.mybatisplus.extensions.typehandler.IJsonTypeHandler;
import org.apache.ibatis.type.JdbcType;
import org.apache.ibatis.type.ObjectTypeHandler;

import java.sql.PreparedStatement;
import java.sql.SQLException;

/**
 * @author Ye Junhui
 * @since 2024/4/26
 */
public abstract class AbstractJsonObjectTypeHandler extends ObjectTypeHandler implements IJsonTypeHandler<Object> {

    @Override
    public void setNonNullParameter(PreparedStatement ps, int i, Object parameter, JdbcType jdbcType)
            throws SQLException {
        ps.setObject(i, toJson(parameter));
    }

}
